﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RooHui.Infrastructure.Entities.Repository;

namespace RooHui.Infrastructure.Entities.Entity
{
    public class City : IAccessible<P_City, City>, ILogicEntity<P_City, City>
    {
        public string CityCode { get; set; }

        public string CityName { get; set; }

        public string ProvinceCode { get; set; }

        protected override void Covariant(P_City model)
        {
            if (model != null)
            {
                this.ProvinceCode = model.ProvinceCode;
                this.CityCode = model.CityCode;
                this.CityName = model.CityName;
            }
        }

        protected override P_City Inverter(City model)
        {
            if (model != null)
            {
                return new P_City()
                {
                    ProvinceCode = model.ProvinceCode,
                    CityName = model.CityName,
                    CityCode = model.CityCode

                };
            }
            return null;
        }

        public City Set(P_City dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
